/*
*  Copyright 2019-2020 Zheng Jie
*
*  Licensed under the Apache License, Version 2.0 (the "License");
*  you may not use this file except in compliance with the License.
*  You may obtain a copy of the License at
*
*  http://www.apache.org/licenses/LICENSE-2.0
*
*  Unless required by applicable law or agreed to in writing, software
*  distributed under the License is distributed on an "AS IS" BASIS,
*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*  See the License for the specific language governing permissions and
*  limitations under the License.
*/
package com.alien.admin.modules.container.domain;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author zhouseyi
* @date 2021-10-19
**/
@Entity
@Data
@IdClass(K8sDeploymentStatusId.class)
@Table(name="dp_k8s_deployment_status")
public class K8sDeploymentStatus implements Serializable {

    @Id
    @Column(name = "k8s_id")
    @NotNull
    @ApiModelProperty(value = "集群id")
    private Integer k8sId;

    @Id
    @Column(name = "namespace",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "namespace")
    private String namespace;

    @Id
    @Column(name = "deployment_name",nullable = false)
    @NotBlank
    @ApiModelProperty(value = "deploymentName")
    private String deploymentName;

    @Column(name = "replicas")
    @ApiModelProperty(value = "replicas")
    private Integer replicas;

    @Column(name = "updated_replicas")
    @ApiModelProperty(value = "updatedReplicas")
    private Integer updatedReplicas;

    @Column(name = "ready_replicas")
    @ApiModelProperty(value = "readyReplicas")
    private Integer readyReplicas;

    @Column(name = "available_replicas")
    @ApiModelProperty(value = "availableReplicas")
    private Integer availableReplicas;

    @Column(name = "limit_cpu")
    @ApiModelProperty(value = "limitCpu")
    private String limitCpu;

    @Column(name = "limit_mem")
    @ApiModelProperty(value = "limitMem")
    private String limitMem;

    @Column(name = "request_cpu")
    @ApiModelProperty(value = "requestCpu")
    private String requestCpu;

    @Column(name = "request_mem")
    @ApiModelProperty(value = "requestMem")
    private String requestMem;

    public void copy(K8sDeploymentStatus source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
    }
}